package day18.pack7;

import lombok.SneakyThrows;
/*
1 重写clone，放大权限。否则其他类用不到，权限不足。
2. 授权。。



 */
public class Test {
    @SneakyThrows
    public static void main(String[] args) {
        Student student = new Student("猪小明", 10, new Teacher("皮特"));
        Student newStudent = student.clone();

        newStudent.getTeacher().setTeacherName("唐三藏");
        newStudent.setStudentName("猪八戒");

        System.out.println(newStudent.getStudentName());
        System.out.println(newStudent.getTeacher().getTeacherName());

        System.out.println(student.getStudentName());
        System.out.println(student.getTeacher().getTeacherName());

//        System.out.println(newStudent);
//        System.out.println(newStudent == student);
//        System.out.println(student.getTeacher() == newStudent.getTeacher());

    }
}
